// 初始化玩家控制
import EventUtil from '@kernel/util/event_util'
import {KEYBORD_KEY} from '@kernel/constant/keyboard'
import KPlayer from '@kernel/util/player'
import KUnit from '@kernel/util/unit'

const InitPlayerControl = () => {
  EventUtil.register('KEYBOARD_KEY_UP_EVENT', (data) => {
    if (<number>data.__current_key == KEYBORD_KEY.F1) {
      const player = KPlayer.fromId(data.__role_id)
      const hero = player.getData<KUnit>('hero')
      player.selectUnit(hero)
    }
  })
}

export default InitPlayerControl
